package com.bangdao.app.jetpacktest.jetpack.viewbinding;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.Toast;

import com.bangdao.app.jetpacktest.databinding.ActivityViewBindingBinding;


public class ViewBindingActivity extends AppCompatActivity {

    private ActivityViewBindingBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityViewBindingBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());//R.layout.activity_view_binding

        initData();
        initEvent();
    }

    private void initData() {
        binding.tvContent.setText("哈哈哈");
    }

    private void initEvent() {
        binding.btn1.setOnClickListener(view -> {
            Toast.makeText(this, "点击按钮1", Toast.LENGTH_SHORT).show();
        });
        binding.btn2.setOnClickListener(view -> {
            Toast.makeText(this, "点击按钮2", Toast.LENGTH_SHORT).show();
        });
    }
}